package cn.cnf.controller;

import cn.cnf.common.StringPool;
import cn.cnf.common.utils.JwtTokenUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author ZhuMeiYi
 * @date 2021/2/14 18:14
 * @description
 */
@Controller
@RequestMapping("/password")
public class HtmlController {
    @GetMapping("/newPassword")
    public String newPassword(@RequestParam("token")String token) {
        if (!StringPool.PASSWORD_RESET_MARK.equals(JwtTokenUtil.getUserRole(token))) {
            return "/error.html";
        }
        String username = JwtTokenUtil.getUsername(token);
        return "/resetPassword.html?token="+token+"&username="+username;
    }
}
